#include "stdio.h"
#include "Motor.cpp"

int main()
{
	mouseDelta mickey;
	int i, sumX, sumY;

/*
	FILE *fmouse;
	fmouse = fopen("/dev/input/mice","r");
	int buffer[WINDOW][2];
	bool reset = false;
	while(1)
	{
		mickey = getMouse(fmouse);
		printf("xd=%d, yd=%d\n", mickey.dx, mickey.dy);
		buffer[0][0] = mickey.dx;
		buffer[0][1] = mickey.dy;
		sumX = 0;
		sumY = 0;

		for(i = 0; i < WINDOW-1; i++)
		{
			sumX += buffer[i][0];
			sumY += buffer[i][1];
			buffer[i+1][0] = buffer[i][0];
			buffer[i+1][1] = buffer[i][1];
			buffer[0][0] = 0;
			buffer[0][1] = 0;
			
			if(sumX >= TRESHOLD)
			{
				goRight(0x50, 1);
				reset = true;
				sleep(1);
				stop();
			}
			else if(sumX <= -TRESHOLD)
			{
				goLeft(0x50, 1);
				reset = true;
				sleep(1);
				stop();
			}
			else if(sumY >= TRESHOLD)
			{
				goForward(0x50);
				sleep(2);
				stop();
				reset = true;
			}
			else if(sumY <= -TRESHOLD)
			{
				goBackward(0x30);
				sleep(2);
				stop();
				reset = true;
			}
			if(reset == true)
			{
				for(i = 0; i < WINDOW; i++)
				{
					buffer[i][0] = 0;
					buffer[i][1] = 0;
				}
				reset = false;
				sumX = 0;
				sumY = 0;
				getMouse(fmouse);
				getMouse(fmouse);
			}
			
		}
	}
	
	fclose(fmouse);
*/
	Drive(100);
	sleep(2);
	Drive(0);
	Rotate(45, true);
	return 0;
}
